using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using System.IO;

namespace Macaw.Wss3.LookupFieldControlAdapter
{
    class LookupFieldControlAdapterFeature : SPFeatureReceiver
    {

        public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPWebApplication webApplication = properties.Feature.Parent as SPWebApplication;
            if (webApplication == null) return;

            LookupFieldControlAdapterJobDefinition job = new LookupFieldControlAdapterJobDefinition(LookupFieldControlAdapterJobDefinition.JobName, webApplication)
            {
                Installing = true,
                Schedule = new SPOneTimeSchedule(DateTime.Now)
            };
            job.Update();
        }

        public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
        {
            SPWebApplication webApplication = properties.Feature.Parent as SPWebApplication;
            if (webApplication == null) return;

            LookupFieldControlAdapterJobDefinition job = new LookupFieldControlAdapterJobDefinition(LookupFieldControlAdapterJobDefinition.JobName, webApplication)
            {
                Installing = false,
                Schedule = new SPOneTimeSchedule(DateTime.Now)
            };
            job.Update();
        }

        public override void FeatureInstalled(SPFeatureReceiverProperties properties)
        {

        }

        public override void FeatureUninstalling(SPFeatureReceiverProperties properties)
        {

        }
    }
}
